/**
 * @description 所以一个问卷的所有答卷列表如
 */

const mock = require('mockjs')
const Random = mock.Random
const getComponentList = require('./getComponentList')

function getStateList(len = 10) {
  const componentList = getComponentList()
  const arr = []
  for (let i = 0; i < len; i++) {
    const obj = {
      _id: Random.id()
    }
    componentList.forEach((item, index) => {
      switch (item.type) {
        case 'questionInput':
          obj[item.fe_id] = Random.ctitle()
          break
        case 'questionTextarea':
          obj[item.fe_id] = Random.csentence(5, 20)
          break
        case 'questionRadio':
          obj[item.fe_id] = item.props.options[Random.integer(0, 2)].text
          break
        case 'questionCheckbox':
          obj[item.fe_id] = `${item.props.list[Random.integer(0, 1)].text},${item.props.list[2].text}`
          break
      }
    })
    arr.push(obj)
  }
  return arr
}

module.exports = getStateList
